﻿using System;
using System.Data;
using System.Data.Common;
using Songhay.Data.GenericWeb.Properties;

namespace Songhay.Data.GenericWeb.Procedure
{
    /// <summary>
    /// Insert procedures for Web-schema data.
    /// </summary>
    internal static partial class Insert
    {
        internal static void DocumentKeyword(DbConnection connection, object documentID, object keywordValue)
        {
            if(connection == null) throw new ArgumentNullException("connection", "The connection is null.");

            using(DbCommand cmd = connection.CreateCommand())
            {
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = Resources.InsertDocumentKeyword;

                DbParameter parameter;

                parameter = cmd.CreateParameter();
                parameter.ParameterName = "@DocumentId";
                parameter.Value = documentID;
                cmd.Parameters.Add(parameter);

                parameter = cmd.CreateParameter();
                parameter.ParameterName = "@KeywordValue";
                parameter.Value = keywordValue;
                cmd.Parameters.Add(parameter);

                cmd.ExecuteNonQuery();
            }
        }
    }
}
